package com.yzh.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

@Configuration //配置类
@EnableSwagger2// 开启Swagger2的自动配置
public class SwaggerConfig {
    // 配置Swagger
    @Bean
    public Docket docket(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .groupName("杨振华")
                .enable(true)
                .select()
                //RequestHandlerSelectors 配置扫描接口的方式
                .apis(RequestHandlerSelectors.basePackage("com.yzh.controller"))
                .build()
                ;
    }
    /**
     * 配置Swagger信息=apiInfo
     *
     * @return {@link ApiInfo}
     */
    private ApiInfo apiInfo(){

        Contact contact=new Contact("杨振华","https://blog.csdn.net/AN_NI_112?spm=1000.2115.3001.5343","3480088617@qq.com");

        return new ApiInfo(
                "第一个信息管理程序",
                "静待花开，清风自来",
                "y1.0",
                "https://blog.csdn.net/AN_NI_112?spm=1000.2115.3001.5343",
                contact,
                "Apache 2.0",
                "许可链接", // 许可连接
                new ArrayList<>()// 扩展
        );
    }

}